package com.godpaper.as9.commands
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.adobe.cairngorm.view.ViewLocator;
	import com.godpaper.as9.bussiness.delegates.PhotoDelegate;
	import com.godpaper.as9.events.GetPhotoListEvent;
	import com.godpaper.as9.model.PhotoModelLocator;
	import com.godpaper.as9.view.ExplorerHelper;
	
	import mx.rpc.IResponder;

	public class GetPhotoListCommand extends CommandBase implements ICommand, IResponder
	{
		private var delegate:PhotoDelegate;
		private var photoModel:PhotoModelLocator = PhotoModelLocator.getInstance();
		private var getPhotoListEvent:GetPhotoListEvent;
		public function GetPhotoListCommand()
		{
			super();
			delegate = new PhotoDelegate(this);
		}
		
		override public function execute(event:CairngormEvent):void
		{
			getPhotoListEvent = GetPhotoListEvent(event);
			
			delegate.getPhotoList(getPhotoListEvent.albumID);
		}
		
		override public function result(data:Object):void
		{
//			trace(data.result);
			(ViewLocator.getInstance().getViewHelper("explorerHelper") as ExplorerHelper).display();
			photoModel.photoList.source = data.result;
		}
		
		
	}
}